home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / distill.zip / Distill.CMD next >
OS/2 REXX Batch file  |  1997-07-26  |  7KB  |  132 lines

  1. /**********************************************************************/
  2. /*  Distill.CMD                                                       */
  3. /*  -----------                                                       */
  4. /*  This REXX routine will take a raw postscript file and feed it     */
  5. /*  through Aladdin Ghostscript in order to produce an Acrobat        */
  6. /*  Portable Document Format (PDF) file.  Input is the file name of   */
  7. /*  the raw postscript file.  If input is specified as "STDIN" it     */
  8. /*  will accept the input from the STDIN device.  This makes it       */
  9. /*  possible to use this REXX program with Kai Uwe Rommel's freeware  */
  10. /*  PRINTMON program to produce Acrobat documents on the fly.         */
  11. /*                                                                    */
  12. /*  To use this program with PRINTMON to produce Acrobat documents    */
  13. /*  directly, you must create a Printer object using the Generic      */
  14. /*  Postscript Printer driver for OS/2.  For best results, always     */
  15. /*  use the latest Postscript printer driver from IBM (at this        */
  16. /*  writing, it is 30.515).  Assign the printer to a port (for        */
  17. /*  example, LPT3).                                                   */
  18. /*                                                                    */
  19. /*  Next, add the following line to your STARTUP.CMD file:            */
  20. /*                                                                    */
  21. /*      START /MIN PRINTMON LPTx "Distill STDIN"                      */
  22. /*                                                                    */
  23. /*  (The above assumes that PRINTMON.EXE and DISTILL.CMD are in your  */
  24. /*  path).  Whenever you print to the Postscript printer object, a    */
  25. /*  pop-up dialog box should appear prompting you for a file name     */
  26. /*  for your document.  Enter the name and press the "OK" button.     */
  27. /*  That's all there is to it!                                        */
  28. /*                                                                    */
  29. /*  Requirements:                                                     */
  30. /*     Kai Uwe Rommel's PRINTMON.EXE                                  */
  31. /*     Aladdin Ghostscript                                            */
  32. /*     Postscript Printer object                                      */
  33. /*     IBM EWS Visual REXX Extensions (VREXX)                         */
  34. /*     EMX Run Time environment                                       */
  35. /*     Adobe's Acrobat Reader for OS/2 or                             */
  36. /*        Russell Lang's GSView for OS/2                              */
  37. /**********************************************************************/
  38. '@ECHO OFF'
  39. gsdir = 'E:\gs5.01'             /* Directory where Ghostscript lives  */
  40.  
  41. /**********************************************************************/
  42. /*  Just fill in the required path for one of the two following       */
  43. /*  variables.  If you want to use Adobe's Acrobat reader, fill out   */
  44. /*  the acdir = line with the appropriate directory.  If you want     */
  45. /*  to use Russell Lang's GSView program, fill in the gvdir = line.   */
  46. /*  If both are specified, Acrobat reader will take precedence.       */
  47. /**********************************************************************/
  48. acdir = 'E:\AcroRead'           /* Directory for Adobe Acrobat Reader */
  49. gvdir = ''                      /* Directory for GSView               */
  50.  
  51. path = Directory()              /* Get current directory              */
  52. path = Strip(path, 'T', '\')    /* Standardize format                 */
  53. /**********************************************************************/
  54. /*  Parse the input file name.  If STDIN, set up so Ghostscript will  */
  55. /*  read from STDIN and create a PDF file with a default name in the  */
  56. /*  temporary directory.  Otherwise, parse the file name and create a */
  57. /*  fully-qualified drive:\path\filename.  If no input file name is   */
  58. /*  specified, just Exit with a bad return code.                      */
  59. /**********************************************************************/
  60. Parse Arg input
  61.  
  62. Select
  63.    When input = '' Then
  64.       Exit 4
  65.    When Translate(input) = 'STDIN' Then
  66.       psname = '-'
  67.    Otherwise
  68.       Do
  69.          psname = Filespec('N', input)
  70.          If psname = input Then
  71.             psname = path || '\' || psname
  72.       End
  73. End
  74.  
  75. /**********************************************************************/
  76. /*  set up the environment for the IBM EWS VREXX extensions, then     */
  77. /*  prompt the user for the name of the new Acrobat document.  Once   */
  78. /*  received, cancel the VREXX environment.                           */
  79. /**********************************************************************/
  80. Call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  81. initcode = VInit()
  82. If initcode \= 'ERROR' Then
  83.    Do
  84.       Call VDialogPos 50, 50
  85.       Call VFileBox 'Name for PDF Document', ,
  86.                      '*.PDF', ,
  87.                      'FNAME'
  88.       pdfname = fname.vstring
  89.  
  90. /**********************************************************************/
  91. /*  Switch to the Ghostscript directory and use Ghostscript to        */
  92. /*  distill the raw postscript file into PDF format.  When done,      */
  93. /*  return to the home directory.                                     */
  94. /**********************************************************************/
  95.       Call Directory gsdir
  96.       'GS -q -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -sOutputFile#' || ,
  97.          pdfname psname
  98.       code = rc
  99.       Call Directory path
  100.  
  101. /**********************************************************************/
  102. /*  If the PDF file was created, prompt the user to see if he wants   */
  103. /*  to launch the Acrobat Reader or GSView to verify it's validity    */
  104. /**********************************************************************/
  105.       If Stream(pdfname, 'C', 'QUERY EXISTS') \= '' & ,
  106.          code = 0 Then
  107.          Do
  108.             Select
  109.                When acdir \= '' Then
  110.                   Do
  111.                      vwdir = acdir || '\'
  112.                      viewer = 'Acrobat'
  113.                      vwpgm = 'ACROREAD'
  114.                   End
  115.                Otherwise
  116.                   Do
  117.                      vwdir = gvdir || '\'
  118.                      viewer = 'GSView'
  119.                      vwpgm = 'GVPM'
  120.                   End
  121.             End
  122.             prompt.0 = 1
  123.             prompt.1 = 'View the document?   '
  124.             If VMsgBox('Launch' viewer, 'PROMPT', 6) = 'YES' Then
  125.                'START' vwdir || ,
  126.                        vwpgm ,
  127.                        pdfname
  128.          End
  129.       Call VExit
  130.    End
  131. Exit
  132.